/**
 * Created by weikexin .
 * description:
 **/
import { HTTP } from '../util/http'

class Payment extends HTTP {
  checkStick(params = {}, success) {
    let url = 'PayController/checkIsAllowStick'
    let data = Object.assign({}, params, {
      userId: wx.getStorageSync('userInfo').user_id || 0
    })
    this.request({
      url: url,
      data: data,
      success
    })
  }

  getPublishInfo(params = {}, success) {
    let url = 'CostSet/queryCostSetByName'
    let data = Object.assign({}, params, {
      userId: wx.getStorageSync('userInfo').user_id || 0
    })
    this.request({
      url: url,
      data: data,
      success
    })
  }

  wxPay(params = {}, success) {
    let url = 'PayController/payWithWeiXin'
    let data = Object.assign({}, params, {
      type: 2,
      userName: wx.getStorageSync('userInfo').user_name || 0
    })
    this.request({
      url: url,
      data: data,
      method: 'POST',
      success
    })
  }
  payForAnother(params = {}, success) {
    let url = 'CollectManagement/collectInformation'
    this.request({
      url: url,
      data: params,
      method: 'POST',
      success
    })
  }
  paySuccess(params = {}, success) {
    // 支付成功后调用 确保支付成功
    let url = 'PayController/paySuccess'
    let data = Object.assign({}, params, {
      type: 2,
      userName: wx.getStorageSync('userInfo').user_name || 0
    })
    this.request({
      url: url,
      data: data,
      method: 'POST',
      success
    })
  }
  notify(params = {}, success) {
    let url = 'PayController/notify'
    let data = Object.assign({}, params, {
      userName: wx.getStorageSync('userInfo').user_name || 0
    })
    this.request({
      url: url,
      data: data,
      method: 'POST',
      success
    })
  }
}

export { Payment }
